package org.mx.test.entity;

import org.mx.dal.entity.BaseDictEntity;

import javax.persistence.*;
import java.util.Set;

@SuppressWarnings("javadoc")
@Entity
@Table(name = "T_ROLE")
public class RoleEntity extends BaseDictEntity {
	private static final long serialVersionUID = -5943751596096578557L;
	@ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "T_USER_ROLE",
            joinColumns = @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID"),
            inverseJoinColumns = @JoinColumn(name = "USER_ID", referencedColumnName = "ID"))
    private Set<UserEntity> users;
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "T_ROLE_PRIVILEGE",
            joinColumns = @JoinColumn(name = "ROLE_ID", referencedColumnName = "ID"),
            inverseJoinColumns = @JoinColumn(name = "PRIVILEGE_ID", referencedColumnName = "ID"))
    private Set<PrivilegeEntity> privileges;

    public Set<UserEntity> getUsers() {
        return users;
    }

    public void setUsers(Set<UserEntity> users) {
        this.users = users;
    }

    public Set<PrivilegeEntity> getPrivileges() {
        return privileges;
    }

    public void setPrivileges(Set<PrivilegeEntity> privileges) {
        this.privileges = privileges;
    }
}
